type p = Promise<'pro'>

type getValue<T> = T extends Promise<infer Value> ? Value : never

type value = getValue<p>

type getFirst<Arr extends number[]> = Arr extends [infer First, ...number[]] ? First : never

type first = getFirst<[1, 2, 3]>

type replaceStr<Str extends string, From extends string, To extends string> = Str extends `${infer front}${From}${infer back}` ? `${front}${To}${back}` : Str

type str = replaceStr<'my name is ?', '?', 'kahoohak'>

type trimRight<Str extends string> = Str extends `${infer Rest}${' ' | '\n' | '\t'}` ? trimRight<Rest> : Str
type trimLeft<Str extends string> = Str extends `${' ' | '\n' | '\t'}${infer Rest}` ? trimLeft<Rest> : Str

type trimRes = trimLeft<trimRight<'   haha   '>>

type getParams<Func extends Function> =  Func extends (...args: infer Args) => unknown ? Args : never

type getReturn<Func extends Function> = Func extends (...args: any[]) => infer returnType ? returnType : never

type funcParams = getParams<(name: string, age: number)=> {}>

type returnType = getReturn<() => 88>

class UserFactory {
    name: string

    constructor(name: string) {
        this.name = name
    }

    getName(this: UserFactory) {
        return 'my name is ' + this.name
    }
}

const kaho = new UserFactory('kaho')

type getThisType<T> = T extends (this: infer ThisType, ...args: any[] ) => any ? ThisType : never 

type ThisType = getThisType<typeof kaho.getName>

// console.log()

export { }